essential complexity การใช้
- The following C program fragment has an essential complexity of four; its CFG is irreducible.
- Brooks claims that the accidental complexity has decreased substantially, and today's programmers spend most of their time addressing essential complexity.
- While Brooks insists that there is no one silver bullet, he believes that a series of innovations attacking essential complexity could lead to significant improvements.
- "' Essential complexity "'is a numerical measure defined by McCabe in his highly cited, 1976 paper better known for introducing cyclomatic complexity.
- Brooks argues that this means that shrinking all the accidental activities to zero will not give the same order-of-magnitude improvement as attempting to decrease essential complexity.
- Thus greater than 1 essential complexity numbers, which can only be obtained for non-structured programs, indicate that they are further away from the structured programming ideal.
- As McCabe explains in his paper, his essential complexity metric was designed to provide a measure of how far off this ideal ( of being completely structured ) a given program was.
- The argument relies on the distinction between accidental complexity and essential complexity, similar to the way Amdahl's law relies on the distinction between " strictly serial " and " parallelizable ".
- The essential complexity measure defined by McCabe is simply the cyclomatic complexity of this irreducible graph, so it will be precisely 1 for all structured programs, but greater than one for non-structured programs.
- For example, the following C program fragment has an essential complexity of 1, because the inner "'if "'statement and the "'for "'can be reduced, i . e . it is a structured program.
- McCabe, defined essential complexity as the cyclomatic complexity of the reduced CFG ( control flow graph ) after iteratively replacing ( reducing ) all structured programming control structures, i . e . those having a single entry point and a single exit point ( for example if-then-else and while loops ) with placeholder single statements.
- McCabe's reduction process is intended to simulate the conceptual replacement of control structures ( and actual statements they contain ) with subroutine calls, hence the requirement for the control structures to have a single entry and a single exit point . ( Nowadays a process like this would fall under the umbrella term of refactoring . ) All structured programs evidently have an essential complexity of 1 as defined by McCabe because they can all be iteratively reduced to a single call to a top-level subroutine.